<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>设备日志管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		function refresh(){
			window.location.reload();
		}
		function sync(){
			var type = $("#type").val();
			var equipmentId = $("#equipmentId").val();
			$("#loader").attr("style","display:initial;");
			$.ajax({
                type: "POST",
                url: "${ctx}/equipment/eleEquipmentLog/sync",
                data: {equipmentId: equipmentId,type:type},
                datatype: "json",
                success: function (data) {
        			$("#loader").attr("style","display:none;");
                	alertx(data.msg);
                },
                error: function (e) {
                    alertx("系统处理失败,请联系管理员!");
                    console.log(e);
                }
            });
		}
		function deleteLog(logId){
			var msg = "确认要删除该设备日志吗？";
			console.log(logId);
			 confirmx(msg, function () {
					$.ajax({
		                type: "POST",
		                url: "${ctx}/equipment/eleEquipmentLog/deleteLog",
		                data: {logId:logId},
		                datatype: "json",
		                success: function (data) {
		                    alertx(data.msg, function () {
		                        window.location.reload();
		                    });
		                },
		                error: function (e) {
		                    alertx("系统处理失败,请联系管理员!");
		                    console.log(e);
		                }
		            });
	                });
		
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<c:if test="${type == 'log' }">
				<li class="active"><a href="${ctx}/equipment/eleEquipmentLog/">设备日志列表</a></li>
		</c:if>
		<c:if test="${type == 'realtime' }">
					<li class="active"><a href="${ctx}/equipment/eleEquipmentLog/">设备界面列表</a></li>
		</c:if>
		
	</ul>
	 <div class="control-group" style="margin-bottom:20px;background-color:#f5f5f5;" > 
	 		<input type="hidden" id ="type" value="${type}" />     
	 		<input type="hidden" id ="equipmentId" value="${equipmentId}" />         
            <a class="btn btn-default btn-lg" onclick="refresh();"><spring:message code='common.refresh'/></a>
        	<a class="btn btn-default btn-lg" onclick="sync();">同步</a>
        	<div id="loader" style="display:none;"><img src="${ctxStatic}/images/loading.gif" style="width:40px"/></div>
    </div>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
			<c:if test="${type == 'log' }">				
				<th>日志名称</th>				
			</c:if>
			<c:if test="${type == 'realtime' }">
				<th>界面名称</th>
			</c:if>
				<th><spring:message code='common.update_time'/></th>
				<th><spring:message code='common.remarks'/></th>
				<shiro:hasPermission name="equipment:eleEquipment:edit"><th><spring:message code='common.operation'/></th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="eleEquipmentLog">
			<tr>
				<td>
					<c:if test="${eleEquipmentLog.type == 'log'}">	
					<a href="${ctx}/equipment/eleEquipmentLog/download?logId=${eleEquipmentLog.id}">
					${eleEquipmentLog.name}
					</a>
					</c:if>
					<c:if test="${eleEquipmentLog.type == 'realtime'}">
					<a href="${ctx}/equipment/eleEquipmentLog/viewPic?logId=${eleEquipmentLog.id}">
					${eleEquipmentLog.name}
					</a>
					</c:if>
					
				</td>
				<td>
					<fmt:formatDate value="${eleEquipmentLog.updateDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<td>
					${eleEquipmentLog.remarks}
				</td>
				<shiro:hasPermission name="equipment:eleEquipment:view"><td>
					<a href="javascript:void(0);" onclick="deleteLog('${eleEquipmentLog.id}');"><spring:message code='common.delete'/></a>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>